package com.wushuu.ce.http;

import com.wushuu.ce.interfaces.IBasePresenter;

import org.xutils.common.Callback;
import org.xutils.common.util.LogUtil;

/**
 * ============================================================
 * <br/>
 * 作 者 :        xyb
 * <br/>
 * 版 本 :        1.0
 * <br/>
 * 创建日期 ：     2016-05-13 下午3:53
 * <br/>
 * 描 述 ：
 * <br/>
 * 修订历史 ：
 * <br/>
 * ============================================================
 **/
public class BaseCommonCallBack implements Callback.CommonCallback<String> {


    private IBasePresenter presenter;
    private int responseCode;


    public BaseCommonCallBack(IBasePresenter presenter, int reponseCode) {
        this.presenter = presenter;
        this.responseCode = reponseCode;
    }

    @Override
    public void onSuccess(String result) {
        LogUtil.d("log success-----> result: " + result);
        presenter.response(result, responseCode);
    }

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        LogUtil.e(ex.getMessage(), ex);
        presenter.response(ex.getMessage(), responseCode);
    }

    @Override
    public void onCancelled(CancelledException cex) {
        LogUtil.e(cex.getMessage(), cex);
    }

    @Override
    public void onFinished() {
        LogUtil.d("-------Finish-------");
    }
}

